import * as service from "../services/myCustomer";
export default {
  namespace: "myCustomer",
  state: {
    text: "page work",
    openDrawer: false
  },
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname, query }) => {
        if (pathname === "/myCustomer") {
          dispatch({
            type: "fetch"
          });
        }
      });
    }
  },
  effects: {
    *fetch({ payload }, { call, put }) {
      yield put({
        type: "save",
        payload: {
          text: "page init"
        }
      });
    },
    *onOpenDrawer({ payload }, { call, put }) {
        console.log(payload);
        
      yield put({
        type: "save",
        payload: {
          openDrawer: payload.openDrawer
        }
      });
    }
  },
  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    }
  }
};
